package sip;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;

/**
 *
 * @author Akanksha Chauhan
 */
public class InsulinSensor {
   
    private static double totalInsulinAmount;
    private static Timer insulinTimer ;
    public void startInsulinBolus(double insulinamount )
    {
        if(checkInsulinStatus(insulinamount))
        {
            Timer timer = new Timer();
            //calculates the amount of insulin to be given per millisecond
            double insulinAmountPerMs = insulinamount / 60000;
            timer.start();
            while(timer.getElapsedTime()<= 60000)
            {
                totalInsulinAmount = totalInsulinAmount - insulinAmountPerMs;
            }
            timer.stop();
        }
       // else
            //alarm;
        
    } 
    public void startInsulinBasalProfile(HashMap hashmap )
    {
       // Clock clock = new Clock();
        // Date date  = clock.GetCurrentTime();
       Calendar calendar = Calendar.getInstance();
       long currentTime = calendar.getTimeInMillis();
       insulinTimer.start();
       while (Timer.status == Timer.Status.RUNNING )
       {
           
       }
    }
    
    public void stopInsulin()
    {
         insulinTimer.stop();
    }
    public void pauseInsulin()
    {
       insulinTimer.pause();
    }
    public void resumeInsulin()
    {
        insulinTimer.resume();
    }
    public boolean checkInsulinStatus(double insulinAmount)
    {
       if(totalInsulinAmount < insulinAmount ) 
       {
           return false;   
       }
       else
           return true;
    }
}
